package com.gupao.prototype.deep;

import lombok.Data;

import java.io.*;
import java.util.Date;

@Data
public class QiTianDaSheng extends Monkey implements Cloneable, Serializable {

    private Date birthday;

    private JinGuBang jinGuBang = new JinGuBang();

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
//        return this.deepClone();
    }

    private Object deepClone() {


        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(bos);
            oos.writeObject(this);

            ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
            ObjectInputStream ois = new ObjectInputStream(bis);
            QiTianDaSheng qiTianDaSheng = (QiTianDaSheng) ois.readObject();
            qiTianDaSheng.setBirthday(new Date());
            return qiTianDaSheng;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
